var e = require;
var t = module;
var o = exports;
var n = o;
Object.defineProperty(n, "__esModule", {value: !0}), (n.SkinLevelData = n.SkinType = void 0);
var i,
    a,
    r = e("Util"),
    s = e("GameData");
((a = i = n.SkinType || (n.SkinType = {})).none = "none"), (a.ad = "ad"), (a.fragment = "fragment");
var c = (function () {
    function e() {
        this._skinList = [];
    }
    return (
        Object.defineProperty(e, "instance", {
            get: function () {
                return e._instance || (e._instance = new e()), e._instance;
            },
            enumerable: !1,
            configurable: !0
        }),
        Object.defineProperty(e.prototype, "skinList", {
            get: function () {
                return this._skinList;
            },
            enumerable: !1,
            configurable: !0
        }),
        (e.prototype.ResetData = function (e) {
            this._skinList = e;
            for (var t = 0; t < this._skinList.length; t++) {
                var o = this._skinList[t];
                (o.index = t),
                    (o.level = Number(r.default.getItem("skin_level_" + o.name, "0"))),
                    (o.isLock = o.SkinType == i.none || "true" == r.default.getItem("skin_isLock_" + o.name, "false")),
                    (o.fragments = Number(r.default.getItem("skin_fragments_" + o.name, "0")));
            }
        }),
        (e.prototype.getSkinLevelByTheme = function (e) {
            return this._skinList.filter(function (t) {
                return t.theme === e;
            });
        }),
        (e.prototype.setSkinIsLock = function (e) {
            r.default.getItem("skin_isLock_" + e, "true");
        }),
        (e.prototype.add_fragments = function (e, t) {
            void 0 === t && (t = 1), (this._skinList[e.index].fragments += t);
            var o = this._skinList[e.index].fragments;
            r.default.setItem("skin_fragments_" + e.name, o + "");
        }),
        (e.prototype.upgrade_level = function (e) {
            var t = this._skinList[e.index],
                o = t.coin[t.level],
                n = s.default.instance.getPlayerCoin();
            s.default.instance.setPlayerCoin(n - o);
            var i = t.upgrade[t.level],
                a = t.fragments;
            (t.fragments = a - i),
                (t.level += 1),
                (t.isLock = !0),
                r.default.setItem("skin_fragments_" + t.name, t.fragments + ""),
                r.default.setItem("skin_isLock_" + e.name, "true"),
                r.default.setItem("skin_level_" + e.name, t.level + "");
        }),
        (e.prototype.upgrade_lock = function (e) {
            var t = this._skinList[e.index],
                o = t.coin[t.level],
                n = s.default.instance.getPlayerCoin();
            s.default.instance.setPlayerCoin(n - o);
            var i = t.upgrade[t.level],
                a = t.fragments;
            (t.fragments = a - i),
                (t.isLock = !0),
                r.default.setItem("skin_fragments_" + t.name, t.fragments + ""),
                r.default.setItem("skin_isLock_" + e.name, "true"),
                r.default.setItem("skin_level_" + e.name, t.level + "");
        }),
        (e._instance = null),
        e
    );
})();
n.SkinLevelData = c;
